Summary
Apache Log4j2 versions 2.0-beta7 through 2.17.0 (excluding security fix releases 2.3.2 and 2.12.4) are vulnerable to a Arbitrary Code Execution attack where an attacker with permission to modify the logging configuration file can construct a malicious configuration using JDBC Appender with a data source referencing a JNDI URI which can execute remote code. This issue is fixed by limiting JNDI data source names to the java protocol in Log4j2 versions 2.17.1, 2.12.4, and 2.3.2.
Product
Apache Log4j2 versions 2.0-beta7 through 2.17.0 (excluding security fix releases 2.3.2 and 2.12.4).
Impact
In case an attacker can modify the logging configuration (due to fetching remote configuration feature in log4j this opens different attack vectors, such as MITM, DNS poisoning, lateral movement after gaining access to a storage node) an Arbitrary Code Execution could be achieved.
Steps to reproduce
Using the same LDAP server as done in the CVE-2021-44228 PoC, all we need to do is to run:
1 | System.setProperty("log4j2.configurationFile","http://127.0.0.1:8888/config.xml"); |
And to serve the following config.xml:
1 |
|
Expected result:
When initializing the logger object, a request to the config.xml will be made. In the loading process, an attempt to load the DataSource will make a request to the LDAP server that will then redirect to a malicious class. In the end, the arbitrary class will be deserialized and run.
Remediation
Update log4j to one of the fixed versions.
Credit
This issue was discovered and reported by Checkmarx Security Researchers Yaniv Nizry and Liad Levy.